// ----------------------------------
// RSDK Project: Sonic 2
// Script Description: Eggman Flame Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// ========================
// Aliases
// ========================

private alias object.value0 : object.timer


// ========================
// Tables
// ========================

// This is probably meant for hitbox top or something... except for the fact its not actually used
// Using it as the value for hitbox top displays hitboxes that suit the animated frame far better so...
private table OOZEggmanFlame_unusedTable
	-4, -12, -20, -24, -24, -20, -12, -4
end table


// ========================
// Events
// ========================

event ObjectUpdate
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		GetTableValue(temp0, object.frame, OOZEggmanFlame_unusedTable) // fetch the value... but don't do anything with it?
		
//		BoxCollisionTest(C_TOUCH, object.entityPos, -8, temp0, 8, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX) // presumably this is how it used to be before?
		BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 0, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
		if checkResult == true
			CallFunction(Player_Hit)
		end if
	next

	object.frame = object.timer
	object.frame >>= 2

	object.timer++
	if object.timer == 32
		object.type = TypeName[Blank Object]
	end if
end event


event ObjectDraw
	DrawSprite(object.frame)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone07")
	if checkResult == true
		LoadSpriteSheet("OOZ/Objects.gif")
		SpriteFrame(-8, -7, 16, 7, 328, 231)
		SpriteFrame(-8, -16, 16, 16, 328, 239)
		SpriteFrame(-8, -24, 16, 24, 345, 231)
		SpriteFrame(-8, -31, 16, 31, 362, 224)
		SpriteFrame(-8, -31, 16, 31, 362, 224)
		SpriteFrame(-8, -24, 16, 24, 345, 231)
		SpriteFrame(-8, -16, 16, 16, 328, 239)
		SpriteFrame(-8, -7, 16, 7, 328, 231)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-8, -7, 16, 7, 380, 55)
		SpriteFrame(-8, -16, 16, 16, 470, 207)
		SpriteFrame(-8, -24, 16, 24, 453, 199)
		SpriteFrame(-8, -31, 16, 31, 380, 63)
		SpriteFrame(-8, -31, 16, 31, 380, 63)
		SpriteFrame(-8, -24, 16, 24, 453, 199)
		SpriteFrame(-8, -16, 16, 16, 470, 207)
		SpriteFrame(-8, -7, 16, 7, 380, 55)
	end if
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone07")
	if checkResult == true
		LoadSpriteSheet("OOZ/Objects.gif")
		SpriteFrame(-8, -24, 16, 24, 345, 231)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-8, -24, 16, 24, 453, 199)
	end if
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
